/// <reference path="../../index.d.ts" />
"use strict"
const Controller = require("egg").Controller
class Messagecontroller extends Controller {
	constructor(ctx) {
		super(ctx)
	}
	async main() {
		let wechatObj = this.ctx.wechatObj
		this.ctx.xmlBody = {
			Content: `你好,你触发了${wechatObj.Event}`,
			MsgType: "text"
		}

		if (wechatObj.FromUserName === "oeO7MwjSBKtJXRSe0PeDerPUse1E") {
			this.ctx.xmlBody.Content = JSON.stringify(wechatObj)
		}
		if (wechatObj.MsgType == "text") {
			await this.service.msg.handText()
			return
		} else if (wechatObj.MsgType == "event") {
			await this.service.msg.handEvent()
			return
		}
	}
}
module.exports = Messagecontroller